<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@include file="/jsp/commons/header.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>光交箱监控系统</title>
    <link rel="stylesheet" type="text/css" media="screen" href="${ctx }/resources/css/screen.css" />
    <%@ include file="/jsp/commons/meta.jsp"%>
    <script type="text/javascript">
        $(function(){
            $("#login_form").validate({
                rules:{
                    name:{
                        required:true
                    },
                    password:{
                        required:true
                    }
                },
                messages:{
                    name:{
                        required:"<font color=red>请输入账号</font>"
                    },
                    password:{
                        required:"<font color=red>请输入密码</font>"
                    }
                },
                  submitHandler: function(form) {
                      var options={
                          beforeSubmit: function(){
                              $('#submitBtn').attr("disabled", true);
                          },
                          success: function(data){
                              if(data){
                                  $("#status").html("<font color='blue'>登录成功，正在跳转...</font>");
                                  window.location.href="${ctx}/user/login.htm";
                              } else {
                                  $("#status").html("<font color='red'>账号或密码错误</font>");
                                  $('#submitBtn').attr("disabled", false);
                              }
                          },
                          error: function   (){
                              $("#status").html("<font color='red'>服务器发生错误</font>");
                              $('#submitBtn').attr("disabled", false);
                          }
                      };
                      $(form).ajaxSubmit(options);
                  }
            });
            $("#regesiter").click(function(){
                window.location.href="${ctx}/user/toRegesiter.htm";
            });
        })
    </script>
</head>
<body>
    <div id="login">
        <div id="loginlogo"></div>
        <div id="loginpanel">
            <div class="panel-h"></div>
            <div class="panel-c">
                <div class="panel-c-l">
                    <form action="${ctx}/user/loginValidate.htm" method="POST" id="login_form">
                        <table cellpadding="0" cellspacing="0">
                            <tbody>
                                <tr>
                                    <td align="left" colspan="2"> 
                                        <div id="status"></div>
                                        <h3>用户信息登录</h3>
                                    </td>
                                </tr> 
                                <tr>
                                    <td align="right">账号：</td><td align="left"><input type="text" name="name" id="txtUsername" class="login-text" /></td>
                                </tr>
                                <tr>
                                    <td align="right">密码：</td><td align="left"><input type="password" name="password" id="txtPassword" class="login-text" /></td>
                                </tr> 
                                <tr>
                                    <td></td>
                                    <td align="left">
                                        <input type="submit" id="submitBtn" value="登录" class="login-btn" />
                                        <a href="${ctx}/user/forgetPassword.htm">忘记密码</a>
                                    </td>
                                </tr> 
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
            <div class="panel-f"></div>
        </div>
        <div id="logincopyright">Copyright © 2012 苏州柏奥 </div>
    </div>
</body>
